<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>

<h:body>
	<h:form id="formCarro">
		<p:messages />
		<p:dataTable var="detalle" value="#{tiendaMB.car.detalles}"
			id="detalleTable">
			<p:column headerText="Nombre">
				<h:outputText value="#{detalle.prodDet.nombre}" />
			</p:column>
			<p:column headerText="Cantidad">
				<h:outputText value="#{detalle.cantidad}" />
			</p:column>
			<p:column headerText="Total">
				<h:outputText value="#{tiendaMB.calcularTotalDetalle(detalle)}">
					<f:convertNumber type="currency" currencySymbol="$" />

				</h:outputText>
			</p:column>
			<p:column headerText="Sumar">
				<p:commandButton icon="ui-icon-circle-plus" id="btnSumar"
					update="@form" action="#{tiendaMB.sumarCantidadDetalle(detalle)}" />
			</p:column>
			<p:column headerText="Restar">
				<p:commandButton icon="ui-icon-circle-minus" id="btnRestar"
					update="@form" action="#{tiendaMB.restarCantidadDetalle(detalle)}" />
			</p:column>
			<p:column headerText="Eliminar">
				<p:commandButton icon="ui-icon-circle-close" id="btnEliminar"
					update="@form" action="#{tiendaMB.eliminarDetalle(detalle)}" />
			</p:column>
			<f:facet name="footer">
				
				Total : <h:outputText id="total" value="#{tiendaMB.calcularTotal()}">
					<f:convertNumber type="currency" currencySymbol="$" />

				</h:outputText>
				<br></br>
			</f:facet>
		</p:dataTable>
		<p:commandButton value="Confirmar" icon="ui-icon-cart"
			id="btnConfirmar" action="#{tiendaMB.confirmarCompra}" />
		<p:commandButton value="Volver" id="btnVolver"
			action="listado_productos" />
	</h:form>
</h:body>

</html>